//
//  YDYVistorView.m
//  DY_Weibo3
//
//  Created by 杨德勇 on 2016/8/17.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYVistorView.h"
@interface YDYVistorView()
/*背景圆圈*/
@property (weak, nonatomic) IBOutlet UIImageView *circleImgView;
/*遮盖*/
@property (weak, nonatomic) IBOutlet UIImageView *maskImgView;
/*中央的图标*/
@property (weak, nonatomic) IBOutlet UIImageView *iconImgView;
/*文字栏*/
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@end

@implementation YDYVistorView

-(void)awakeFromNib{
    [super awakeFromNib];
    
}

-(void)setVistorViewWithTitle:(NSString *)title andImageName:(NSString *) imgName{
    //默认首页样式
    if (title.length == 0){
        [self startAnimation];
        return;
    };
    
    self.titleLabel.text = title;
    self.iconImgView.image = [UIImage imageNamed:imgName];
    self.maskImgView.hidden = YES;
    self.circleImgView.hidden = YES;
    
}
-(void)startAnimation{
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    animation.toValue = @(M_PI * 2.0);
    
    animation.duration = 5.0;
    animation.repeatCount = MAXFLOAT;
    animation.removedOnCompletion = false;
    [self.circleImgView.layer addAnimation:animation forKey:nil];
}

@end
